//
//  HCbriefCustomView.m
//  YOGProj
//
//  Created by liyun on 14-7-21.
//  Copyright (c) 2014年 qkong. All rights reserved.
//
#define offx  10

#import "HCbriefCustomView.h"
#import "HCMacroDefinition.h"

@implementation HCbriefCustomView

- (id)initWithFrame:(CGRect)frame
               type:(int)type
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UILabel *address = [[UILabel alloc] initWithFrame:CGRectMake(offx, 10, 300, 80)];
        address.font = HEIGHT_FONT(17.0f);
        address.textColor = HEX2UIColor(0x333333);
        address.backgroundColor = [UIColor clearColor];
        address.numberOfLines = 0;
        [self addSubview:address];
        
        NSArray *languages = [NSLocale preferredLanguages];
        NSString *currentLanguage = [languages objectAtIndex:0];
        if([currentLanguage isEqualToString:@"zh-Hans"])
        {
            address.frame = CGRectMake(offx, 10, 300, 60);
        }
        
        UIImageView *line1 = [[UIImageView alloc] initWithFrame:CGRectMake(offx, address.frame.size.height+15, 300, 1)];
        line1.backgroundColor = TABLE_LINE;
        [self addSubview:line1];
        
        UIImageView *line2 = [[UIImageView alloc] initWithFrame:CGRectMake(offx, address.frame.size.height+15, 300, 1)];
        line2.backgroundColor = TABLE_LINE;
        [self addSubview:line2];
        int height = address.frame.size.height+15;

        switch (type)
        {
            case 1:
            {
                address.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"地点", @""),NSLocalizedString(@"HC餐厅地点", @"")];
                
                
                UILabel *time1 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height, 300, 60)];
                time1.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"时间", @""),NSLocalizedString(@"HC餐厅备注", @"")];
                time1.font = HEIGHT_FONT(15.0f);
                time1.numberOfLines = 0;
                time1.textColor = HEX2UIColor(0x333333);
                time1.backgroundColor = [UIColor clearColor];
                [self addSubview:time1];
                
                UILabel *time2 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height+35+30, 300, 30)];
                time2.text = NSLocalizedString(@"HC餐厅时间1", @"");
                time2.font = NORMAL_FONT(15.0f);
                time2.textColor = HEX2UIColor(0x898989);
                time2.backgroundColor = [UIColor clearColor];
                [self addSubview:time2];
                
                UILabel *time3 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height+70+30, 300, 30)];
                time3.text = NSLocalizedString(@"HC餐厅时间2", @"");
                time3.font = NORMAL_FONT(15.0f);
                time3.textColor = HEX2UIColor(0x898989);
                time3.backgroundColor = [UIColor clearColor];
                [self addSubview:time3];
                
                UILabel *time4 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height+105+30, 300, 30)];
                time4.text = NSLocalizedString(@"HC餐厅时间3", @"");
                time4.font = NORMAL_FONT(15.0f);
                time4.textColor = HEX2UIColor(0x898989);
                time4.backgroundColor = [UIColor clearColor];
                [self addSubview:time4];
                
                UILabel *eg = [[UILabel alloc] initWithFrame:CGRectMake(offx, height+140+30, 300, 30)];
                eg.text = NSLocalizedString(@"HC餐厅时间4", @"");
                eg.font = NORMAL_FONT(15.0f);
                eg.textColor = HEX2UIColor(0x898989);
                eg.backgroundColor = [UIColor clearColor];
                [self addSubview:eg];
                
                line2.frame = CGRectMake(offx, height+170+30, 300, 1);
            }
                break;
            case 2:
            {
                address.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"地点", @""),NSLocalizedString(@"HC数字媒体中心地点", @"")];
                
                UILabel *time1 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height, 300, 60)];
                time1.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"时间", @""),NSLocalizedString(@"HC数字媒体中心时间", @"")];
                time1.font = HEIGHT_FONT(15.0f);
                time1.textColor = HEX2UIColor(0x333333);
                time1.numberOfLines = 0;
                time1.backgroundColor = [UIColor clearColor];
                [self addSubview:time1];
                
                line2.frame = CGRectMake(offx, height+30+30, 300, 1);
                
            }
                break;
            case 3:
            {
                address.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"地点", @""),NSLocalizedString(@"HC健身服务地点", @"")];
                
                UILabel *time1 = [[UILabel alloc] initWithFrame:CGRectMake(offx, height, 300, 60)];
                time1.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"时间", @""),NSLocalizedString(@"HC健身服务时间", @"")];
                time1.font = HEIGHT_FONT(15.0f);
                time1.numberOfLines = 0;
                time1.textColor = HEX2UIColor(0x333333);
                time1.backgroundColor = [UIColor clearColor];
                [self addSubview:time1];
                
                line2.frame = CGRectMake(offx, height+30+30, 300, 1);
            }
                break;
            case 4:
            {
                [address removeFromSuperview];
                [line1 removeFromSuperview];
                
                UILabel *time1 = [[UILabel alloc] initWithFrame:CGRectMake(offx, 10, 300, 60)];
                time1.text = [NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"时间", @""),NSLocalizedString(@"HC青奥村广场时间", @"")];
                time1.font = HEIGHT_FONT(16.0f);
                time1.textColor = HEX2UIColor(0x333333);
                if(![currentLanguage isEqualToString:@"zh-Hans"])
                {
                    time1.frame = CGRectMake(offx, 10, 300, 80);
                }
                time1.numberOfLines = 0;
                time1.backgroundColor = [UIColor clearColor];
                [self addSubview:time1];
                
                line2.hidden = NO;
                line2.frame = CGRectMake(offx, time1.frame.size.height+15, 300, 1);
            }
                break;
            default:
                break;
        }
        
        NSLog(@"self.frame.size.height==>%f",self.frame.size.height);
        NSLog(@"y==>%f",line2.frame.origin.y+5);
        NSLog(@"height==>%f",self.frame.size.height-line2.frame.origin.y-5);
        UITextView *describe = [[UITextView alloc] initWithFrame:CGRectMake(offx, line2.frame.origin.y+5, 300, self.frame.size.height-line2.frame.origin.y-5)];
        
        switch (type) {
            case 1:
            {
                describe.text = NSLocalizedString(@"HC餐厅简介", @"");
            }
                break;
            case 2:
            {
                describe.text = NSLocalizedString(@"HC数字媒体中心简介", @"");
            }
                break;
            case 3:
            {
                describe.text = NSLocalizedString(@"HC健身服务简介", @"");
            }
                break;
            case 4:
            {
                describe.text = NSLocalizedString(@"HC青奥村广场简介", @"");
            }
                break;
            default:
                break;
        }
        NSLog(@"over");
        describe.editable = NO;
        describe.textColor = HEX2UIColor(0x898989);
        describe.backgroundColor = [UIColor clearColor];
        describe.font = NORMAL_FONT(15.0f);
        
        [self addSubview:describe];
    }
    return self;
}

@end
